package com.wangijun.yuan.core.util;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

public class AesUtil {


    private static SymmetricCrypto getAes() {
        String key = "W8ZcymPbFN+QZfTtNLwMgg==";
        //构建
        return new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key));

    }

    public static String enc(String content) {
        return getAes().encryptHex(content);
    }

    public static String dec(String content) {
        return getAes().decryptStr(content);
    }


    public static void main(String[] args) {
        // 加密解密
        String enced = enc(RandomUtil.randomString(6) + "000000");
        System.out.println(enced);
        String dec = dec(enced);
        System.out.println(dec);
    }
}
